//
//  MineView.swift
//  xgwjinterconnection
//
//  Created by WangWeiShuo on 2025/8/13.
//

import SwiftUI

struct MineView:View {
    @State private var isVoiceOn = true // 语音开关状态
    
    var body: some View {
        
        VStack() {
            // 顶部头像及背景区域
            //                ZStack(alignment: .center) {
            //                    Image("bg_mine").resizable()
            //                        .frame(maxHeight: 280)
            
            VStack(spacing: 8) {
                Image("default_head")
                    .resizable()
                    .scaledToFit()
                    .frame(width: 80, height: 80)
                    .background(Color.orange)
                    .clipShape(Circle())
                
                Text("Admin")
                    .font(.title)
                    .foregroundColor(.white)
            }.padding(.leading)
                .frame(maxWidth:.infinity,maxHeight: 200)
                .background(
                    Image("bg_mine")
                        .resizable()
                        .edgesIgnoringSafeArea(.all)
                )
            //                }.padding(.leading)
            
            // 用户管理行
            Button {
                print("用户管理详情") // 跳转目标页面，实际替换
            } label: {
                HStack {
                    Image(systemName: "person.2")
                        .foregroundColor(.gray)
                    Text("用户管理").foregroundColor(.black)
                    Spacer()
                    Image(systemName: "chevron.right")
                        .foregroundColor(.gray)
                }
                .padding()
                .background(Color.white)
                .cornerRadius(8)
                .shadow(color: Color.gray.opacity(0.2), radius: 4, x: 0, y: 2)
                .padding(.horizontal, 16)
                .padding(.top, 8)
            }
            
            // 语音开关行
            HStack {
                Image(systemName: "waveform")
                    .foregroundColor(.gray)
                Text(NSLocalizedString("mine_voice", comment: "语音")).foregroundColor(.black)
                Spacer()
                Toggle(isOn: $isVoiceOn) {
                }
                .toggleStyle(SwitchToggleStyle(tint: .blue))
            }
            .padding()
            .background(Color.white)
            .cornerRadius(8)
            .shadow(color: Color.gray.opacity(0.2), radius: 4, x: 0, y: 2)
            .padding(.horizontal, 16)
            .padding(.top, 8)
            
            // 检查更新行
            Button{
                
            }label: {
                Image(systemName: "arrow.clockwise")
                    .foregroundColor(.gray)
                Text("检查更新").foregroundColor(.black)
                Spacer()
                Text("v1.0.0")
                    .foregroundColor(.gray)
            }
            .padding()
            .background(Color.white)
            .cornerRadius(8)
            .shadow(color: Color.gray.opacity(0.2), radius: 4, x: 0, y: 2)
            .padding(.horizontal, 16)
            .padding(.top, 8)
            
            // 服务热线行
            NavigationLink() {
                HotlineView()
            } label: {
                HStack {
                    Image(systemName: "headphones")
                        .foregroundColor(.gray)
                    Text(NSLocalizedString("mine_hotline", comment: "服务热线")).foregroundColor(.black)
                    Spacer()
                    Image(systemName: "chevron.right")
                        .foregroundColor(.gray)
                }
                .padding()
                .background(Color.white)
                .cornerRadius(8)
                .shadow(color: Color.gray.opacity(0.2), radius: 4, x: 0, y: 2)
                .padding(.horizontal, 16)
                .padding(.top, 8)
            }
            
            // 退出登录行
            Button {
                // 处理退出登录逻辑
                print("退出登录")
            } label: {
                HStack {
                    Image(systemName: "arrow.uturn.backward")
                        .foregroundColor(.gray)
                    Text(NSLocalizedString("login_out", comment: "退出登录")).foregroundColor(.black)
                    Spacer()
                    Image(systemName: "chevron.right")
                        .foregroundColor(.gray)
                }
                .padding()
                .background(Color.white)
                .cornerRadius(8)
                .shadow(color: Color.gray.opacity(0.2), radius: 4, x: 0, y: 2)
                .padding(.horizontal, 16)
                .padding(.top, 8)
            }
            
            Spacer()
        }
    }
    
}


#Preview {
    MineView()
}
